// Conway's Game of Life in C++
// Copyright (c) 2006-2008 Antoine Kalmbach <anhekalm{at}cc.jyu[dot]fi>
//
// Permission to use, copy, modify, distribute and sell this software for any 
// purpose is hereby granted without fee, provided that the above copyright 
// notice appear in all copies and that both that copyright notice and this 
// permission notice appear in supporting documentation.

#ifndef __GRID_H
#define __GRID_H

#include "cell.h"

#include <vector>
#include <iostream>
#include <stdexcept>

namespace Life {

class Grid
{
private:
    std::vector<std::vector<Cell> > grid;
    int xs, ys;
    bool isOutOfBoundaries(int x, int y);
public:
    Grid(int xs_, int ys_);
    virtual ~Grid() {}

    int width() const { return xs; }
    int height() const { return ys; }
    void kill(int x, int y);
    void ress(int x, int y);
    void set(int x, int y, bool status);
    void clear();
    void grow(int x, int y);
    void growX(int x);
    void growY(int y);
    Cell getCell(int x, int y);
    bool isAlive(int x, int y);
    void resize(int xs_, int ys_);

    // text
    void output(std::ostream &os);
};

}

#endif

